package com.ruoyi.web.controller.pc;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.WmsInventoryRecord;
import com.ruoyi.business.service.IWmsInventoryRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 盘点单Controller
 *
 * @author ruoyi
 * @date 2024-01-21
 */
@RestController
@RequestMapping("/business/inventoryRecord")
public class WmsInventoryRecordController extends BaseController
{
    @Autowired
    private IWmsInventoryRecordService wmsInventoryRecordService;

    /**
     * 查询盘点单列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WmsInventoryRecord wmsInventoryRecord)
    {
        startPage();
        List<WmsInventoryRecord> list = wmsInventoryRecordService.selectWmsInventoryRecordList(wmsInventoryRecord);
        return getDataTable(list);
    }

//    /**
//     * 导出盘点单列表
//     */
//    @Log(title = "盘点单", businessType = BusinessType.EXPORT)
//    @GetMapping("/export")
//    public AjaxResult export(WmsInventoryRecord wmsInventoryRecord)
//    {
//        List<WmsInventoryRecord> list = wmsInventoryRecordService.selectWmsInventoryRecordList(wmsInventoryRecord);
//        ExcelUtil<WmsInventoryRecord> util = new ExcelUtil<WmsInventoryRecord>(WmsInventoryRecord.class);
//        return util.exportExcel(list, "盘点单数据");
//    }

    /**
     * 获取盘点单详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wmsInventoryRecordService.selectWmsInventoryRecordById(id));
    }

    /**
     * 新增盘点单
     */
    @Log(title = "盘点单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsInventoryRecord wmsInventoryRecord)
    {
        return toAjax(wmsInventoryRecordService.insertWmsInventoryRecord(wmsInventoryRecord));
    }

    /**
     * 修改盘点单
     */
    @Log(title = "盘点单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsInventoryRecord wmsInventoryRecord)
    {
        return toAjax(wmsInventoryRecordService.updateWmsInventoryRecord(wmsInventoryRecord));
    }

    /**
     * 删除盘点单
     */
    @Log(title = "盘点单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wmsInventoryRecordService.deleteWmsInventoryRecordByIds(ids));
    }
}
